# -*- coding:utf-8 -*-
"""
Created on Jun 6, 2011

@author: Lithuanian
"""
from bond import Bond
from loa_example import AlphaBetaAgent
from game_runner import GameRunner, agents
from loa_game import WHITE, BLACK
class Tester():
    
    def initAgentTime(self):
        Wagent = Bond()
        Bagent = AlphaBetaAgent()
        time = [10,20,30,40,50]
        exp = Experiment(Wagent, "Bond" ,Bagent, "alphaBeta", time, True)
        return exp
        
    def agentTime(self):
        exp = self.initAgentTime()
        agents[WHITE] = exp.white
        agents[BLACK] = exp.black
        if exp.isTimeList:
            if exp.isTurnTimeTest:
                for time in exp.turnTime:
                    gr = GameRunner(None, agents, time, exp.setupTime)
            if exp.isSetupTimeTest:
                for setup in exp.setupTime:
                    gr = GameRunner(None, agents, exp.turnTime, setup)
        else:
            gr = GameRunner(None, agents, exp.turnTime, exp.setupTime)
            self.runGame(gr)
            
    def runGame(self, gr):
        '''
        @param gr: game runner object 
        '''
        winner = gr.run()
        
class Experiment():
    def __init__(self, Wagent, whiteName, Bagent, blackName, isTurnTimeTest, turnTime, setupTime, \
                 isTurnTimeTest, isSetupTimeTest):
        self.white              = Wagent
        self.whiteName          = whiteName
        self.black              = Bagent
        self.blackName          = blackName
        self.turnTime           = turnTime
        self.setupTime          = setupTime
        self.isTurnTimeTest     = isTurnTimeTest
        self.isSetupTimeTest    = isSetupTimeTest
